package CoreClass;

public class Mk_log
{
	public Mk_log()
	{
	}

	public final void logToDataBase(int userid, String username, String mk_num, String msg, String Logtime)
	{
		String strSql = String.Concat(new Object[] {"insert mk_rizhi(id2,user_name,mk_num,addtime,operation) values(", userid, ",'", username, "','", mk_num, "','", Logtime, "','", msg, "')"});
		(new DBCommon()).ExcuteSql(strSql);
	}

	public final void logToTextFile(String path, String msg, String source)
	{
		if (((path != null) && (msg != null)) && (source != null))
		{
			try
			{
				if ((new java.io.File(path)).isFile())
				{
					if ((new java.io.File(path)).length() < Mk_log_config.LogMaxSize)
					{
						this.WriteToFile(path, msg, source);
					}
				}
				else
				{
					this.WriteToFile(path, msg, source);
				}
			}
			catch (RuntimeException e)
			{
				System.out.println("\u5199\u5165\u6587\u4ef6\u65f6\u51fa\u73b0\u5f02\u5e38: " + e);
			}
		}
	}

	private void WriteToFile(String path, String msg, String source)
	{
		StreamWriter sw = new StreamWriter(path, true);
		sw.Write(source + msg);
		sw.Close();
	}
}